package com.zxy.ziems.server.log.controller;

import com.zxy.btp.common.response.JsonResponse;
import com.zxy.btp.common.response.PageResult;
import com.zxy.ziems.server.log.pojo.param.DataRecordParam;
import com.zxy.ziems.server.log.pojo.vo.DataRecordLogVO;
import com.zxy.ziems.server.log.pojo.vo.DataRecordVO;
import com.zxy.ziems.server.log.service.DataRecordLogService;
import com.zxy.ziems.server.log.service.DataRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 数据操作记录
 */
@RestController
@RequestMapping("/api/data/record")
public class DataRecordController {

    @Autowired
    private DataRecordService dataRecordService;
    @Autowired
    private DataRecordLogService dataRecordLogService;

    /**
     * 分页列表
     * @param param
     * @return
     */
    @GetMapping("/page")
    PageResult<DataRecordVO> page(DataRecordParam param) {
        return dataRecordService.page(param);
    }

    /**
     * 获取详细记录
     * @param dataRecordId
     * @return
     */
    @GetMapping("/getLogs")
    JsonResponse<List<DataRecordLogVO>> getLogs (@RequestParam("dataRecordId")String dataRecordId) {
        return JsonResponse.SUCCESS(dataRecordLogService.getByDataRecordId(dataRecordId));
    }
}
